package com.sesame.controller;

import kim.sesame.common.web.controller.AbstractWebController;
import kim.sesame.common.result.ApiResult;
import lombok.extern.apachecommons.CommonsLog;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * 生产
 */
@CommonsLog
@RestController
@RequestMapping("/test")
public class TestController extends AbstractWebController {

    @RequestMapping("/getData")
    public ApiResult getData(String name){
        String str = "spring-cloud-example-ribbon-service : "+ name;
        log.info(str);
        return success(str);
    }

    /**
     * 测试请求方式
     * @param name
     * @return
     */
    @RequestMapping("/testReqType")
    public ApiResult testReqType(String name, String pwd, HttpServletRequest req){
        String method = req.getMethod();

        Map<String,String> map = new HashMap<>();
        map.put("method",method);
        map.put("name",name);
        map.put("pwd",pwd);

        return success(map);
    }
}
